{% extends "base.html" %}
{% load staticfiles %}
{% block title %}
    {{ newName }}

{% endblock %}
{% block content %}
    <link href="{% static 'css/news.css' %}" rel="stylesheet">  <!-- 待创建-->
    <!-- 广告横幅-->
    <div class="container-fluid">
        <div class="row">
            <img class="img-responsive model-img" src="{% static 'img/new.jpg' %}">
        </div>
    </div>

    <!--主体内容-->
    <div class="container">
        <div class="row row-3">
            <!--侧边导航栏-->
            <div class="col-md-3">
                <div class="model-title">
                    新闻动态
                </div>
                <div class="model-list">
                    <ul class="list-group">
                        <li class="list-group-item" id="company">
                            <a href="{% url 'newsApp:news' 'company' %}"> 企业要闻 </a>
                        </li>
                        <li class="list-group-item" id="industry">
                            <a href="{% url 'newsApp:news' 'industry' %}"> 行业新闻</a>
                        </li>
                        <li class="list-group-item" id="notice">
                            <a href="{% url 'newsApp:news' 'notice' %}"> 通知公告</a>
                        </li>
                    </ul>
                </div>
            </div>
            <!--产品的说明文字后和图片-->
            <div class="col-md-9">
                <div class="model-details-title">
                    {{ newName }}
                    <div class="col-md-7 hidden-xs model-details-title-search">
                        <form method="get" id="searchform" action="{% url 'haystack_search' %}">
                            <!--newsApp中名为search的路由-->
                            {% csrf_token %} <!--为了防止csrf（跨站请求伪造）-->
                            <div class="input-group"> <!--bootstrap-->
                                <input type="text" name="q" class="form-control" placeholder="请输入关键词" required>
                                <span class="input-group-btn">
                                    <input type="submit" class="btn btn-default" value="查询">
                                </span>
                            </div>
                        </form>
                    </div>

                </div>
                <div class="model-details">

                    {% for mynew in newList %}   <!--newList为后台传过来的新闻数据-->
                        <div class="news-model">
                            <img src="{% static 'img/newsicon.gif' %}">
                            <a href="{% url 'newsApp:newDetail' mynew.id %}"> <b>{{ mynew.title }}</b> </a>
                            {#                        <a href="#"> <b>{{ mynew.title }}</b> </a>#}
                            <span> 【{{ mynew.publishDate|date:"Y-m-d" }}】</span>
                            <p>
                                <!--添加新闻简要说明-->
                                {{ mynew.mytxt|truncatechars:"110" }}...
                            </p>
                        </div>
                    {% endfor %}

                    {% if pageData %}
                        <div class="paging">
                            <ul id="pages" class="pagination pagination-sm pagination-xs">
                                {% if pageData.first %}
                                    <li><a href="?page=1">1</a></li>
                                {% endif %}
                                {% if pageData.left %}
                                    {% if pageData.left_has_more %}
                                        <li><span>...</span></li>
                                    {% endif %}
                                    {% for i in pageData.left %}
                                        <li><a href="?page={{ i }}">{{ i }}</a></li>
                                        <!--单击时会将参数page的值封装到request中，后台从request中得到page变量值-->
                                    {% endfor %}
                                {% endif %}
                                <li class="active"><a href="?page={{ pageData.page }}">{{ pageData.page }}</a></li>
                                {% if pageData.right %}
                                    {% for i in pageData.right %}
                                        <li><a href="?page={{ i }}">{{ i }}</a></li>
                                    {% endfor %}
                                    {% if pageData.right_has_more %}
                                        <li><span>...</span></li>
                                    {% endif %}
                                {% endif %}
                                {% if pageData.last %}
                                    <li><a href="?page={{ pageData.total_pages }}">{{ pageData.total_pages }}</a></li>
                                {% endif %}
                            </ul>
                        </div>
                    {% endif %}

                </div>
            </div>
        </div>
    </div>
{% endblock %}


